var bg = chrome.extension.getBackgroundPage()
$(function () {
  var state = $('#state')
  var showTimes = $('#showTimes')
  if (bg.state.isReFlash) {
    state.html('正在刷新中...')
  } else {
    state.html('')
  }
  showTimes.html('已经自动刷新' + bg.count + '次')
  $('#begin').click(function () { // 给对象绑定事件
    bg.state.isReFlash = true
    bg.state.ping = Math.max($('#pinlv').val() - 0, 10)
    $('#pinlv').val(bg.state.ping)
    bg.beginFlash(function () {
      showTimes.html('已经自动刷新' + bg.count + '次')
    })
    state.html('正在刷新中...')
  })
  $('#stop').click(function () {
    bg.state.isReFlash = false
    showTimes.html('已经自动刷新' + bg.count + '次')
    bg.count = 0
    state.html('')
  })
})
